<template>
  <view class="suggestion">
    <view v-for="(item, index) in suggestionList" :key="index" class="suggestion_item" @click="choosenItem(item.kw)">
      {{item.kw}}
      <i class="iconfont icon-zuoshang-"></i>
    </view>
  </view>
</template>

<script>
  export default {
    components: {},
    data() {
      return {
        suggestionList: [],
      }
    },
    onLoad() {},
    methods: {
      choosenItem(keyword) {
        this.$emit('handleChoosen', keyword)
      },
      getSuggestions(keyword) {
        // 联想词
        this.$api.dtkapi.getSuggestions({
          version: 'v1.0.2',
          keyWords: keyword,
          type: 2, // 1.大淘客搜索 2.联盟搜索 3.超级搜索
        }).then(res => {
          this.suggestionList = res.data
        })
      }
    }
  }
</script>

<style scoped lang="scss">
  .suggestion {
    .suggestion_item {
      margin: 0 40upx 20upx;
      padding-bottom: 20upx;
      border-bottom: solid 1px #eee;
    }
    .icon-zuoshang- {
      float: right;
    }
  }
</style>
